<?php
/** Description of gpa_new
  * @package
  * @version 0.1
  * @filesource Language.php
  * @author Meta Sanjaya
  * @date 09 Feb 10 7:01:30
  */

class Language
{
    private $_lang = array();

    /** @access public
     * @method __construct
     * @param void
     * @return void
     */
    public function __construct($app, $lang_id)
    {
        include_once __APP__ . $app . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $lang_id . '_' . $app . '.php';
        $this->_lang = $_;
    }

    public function get()
    {
        $args = func_get_args();
        $name = array_shift($args);
        $txt="";
        $str = "\$txt = sprintf('" . $this->_lang[$name] . "'";
        foreach($args as $replace) {
            $str .= ", '" . $replace . "'";
        }
        $str .= ");";
        eval($str);
        return $txt;
    }

    public static function load($app, $lang_id='')
    {
        if(empty($lang_id)) {
            $lang_id = getInstance('config')->get('default_lang');
        }
        
        return(new Language($app, $lang_id));
    }
}
?>
